<%@ page import="rwt.server.util.JspUtil.ClientTrainInitData,java.util.*" %>

<!DOCTYPE html>
<html>
<head>
	<title>Initialize Trains</title>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<link rel="stylesheet" type="text/css" href="/css/style.css" />
	<script type="text/javascript" src="/jquery/jquery-1.8.2.min.js"></script>
	<script type="text/javascript" src="../websock.js"></script>
</head>
<body class="dialog">
	<% 
		List<ClientTrainInitData> trainInitList = 
			(List<ClientTrainInitData>) request.getAttribute("rwt.trainInitData");
	%>
	
	<table class="init_trains">
		<tr>
			<th>Train</th>
			<th>Head Sensor</th>
			<th>Tail Sensor</th>
			<th>Action</th>
		</tr>
	</table>
	<% for (ClientTrainInitData trainInitData : trainInitList)
		{ 
			int trainId = trainInitData.trainId;
		%>
	<div id="divTrain<%=trainId%>" state="<%=trainInitData.isInitialized ? "initialized" : "uninitialized" %>">
		<table class="init_trains">
			<tr>
				<td><%=trainId%></td>
				<td><input id="headSensorTrain<%=trainId%>" type="number" value="<%=trainInitData.headSensor%>" /></td>
				<td><input id="tailSensorTrain<%=trainId%>" type="number" value="<%=trainInitData.tailSensor%>" /></td>
				<td><input id="btnTrain<%=trainId%>" type="button" 
						value="<%=trainInitData.isInitialized ? "Modify" : "Initialize" %>" 
						onclick="initTrain(<%=trainId%>);"/></td>
			</tr>
		</table>
	</div>
	<% } %>
</body>
</html>